import time
from public.action import *
from public.business import *
from public.testData import *
from public.tools import*
from selenium.webdriver.support.select import Select
testCase="DBshop010_销售管理退货管理处理退货"
dr=openBrowser(urlAdmin)
DBshopLoginAdmin(dr)
DBshopEnterMenu2(dr,"销售管理","退货管理")
# 1.点击处理退货，退货处理“同意退货”，退款金额“2199”。处理意见“同意”。
rootPath=get_pro_rootpath()
orderNo=readFile(rootPath+'\public\order2.txt')
dr.find_element_by_xpath('/html/body/div[2]/div/div[2]/table/tbody/tr[1]/td[1]/input').send_keys(orderNo)
dr.find_element_by_xpath('/html/body/div[2]/div/div[2]/table/tbody/tr[1]/td[6]/button/i').click()
dr.find_element_by_link_text('处理退货').click()
s=Select(dr.find_element_by_xpath('//*[@id="refund_state"]'))
s.select_by_visible_text('同意退货')
dr.find_element_by_xpath('//*[@id="refund_price"]').clear()
dr.find_element_by_xpath('//*[@id="refund_price"]').send_keys('2199')
dr.find_element_by_xpath('//*[@id="re_refund_info"]').send_keys('同意')
# 2.提交处理结果。
dr.find_element_by_xpath('/html/body/div[2]/div/div[2]/div/form/div/div[1]/div[2]/button').click()
# 3.回到前台界面，点击“用户中心”，退货申请界面，查看退款成功
dr.get(url)
DBshopLogin(dr,userName,password)
dr.find_element_by_xpath('/html/body/div[1]/div/div[2]/ul/li[4]/a').click()
dr.find_element_by_xpath('/html/body/div[4]/div/div/div[2]/div/div[1]/div/div/a[7]').click()
#断言
if dr.find_element_by_link_text(orderNo).is_displayed():
    writeLog("%s 测试通过" % (testCase))
else:
    writeLog("%s 测试失败" % (testCase))
    getPhoto(dr)
dr.quit()